//成功提示
function showSuccess(msg,text){
    msg = msg || '';
    text = text || '';
    swal(msg, text, "success");
}

//警告提示
function showWarning(msg,text){
    msg = msg || '';
    text = text || '';
    swal(msg,text, "warning");
}

//错误提示
function showError(msg,text){
    msg = msg || '';
    text = text || '';
   swal(msg,text, "error");
}

//确认框
function showConfirm(msg,text,callback){
    msg = msg || '';
    text = text || '';
    if(typeof(callback) == 'function'){
      callback = callback;
    }else{
      callback = function(isConfirm){
        swal({ title: "", text: "", timer: 0, showConfirmButton: false });
      }
    }
    console.log( window.returnResult)
    swal({
        title: msg,
        text: text,
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "是的，我确定！",
        cancelButtonText: "不，我要放弃。",
        closeOnConfirm: false
    }, callback );
}


//用户输入弹出层操作
function showPrompt(msg,text,callback) {
    msg = msg || '';
    text = text || '';
    if(typeof(callback) == 'function'){
      callback = callback;
    }else{
      callback = function(isConfirm){
        swal({ title: "", text: "", timer: 0, showConfirmButton: false });
      }
    }
    swal({
        title:msg,
        text: text,
        type: "input",
        showCancelButton: true,
        closeOnConfirm: false,
        animation: "slide-from-top",
        inputPlaceholder: "在这里填写你想要输入的信息"
    }, function (inputValue) {
        if (inputValue === false) return false;
        if (inputValue === "") {
            swal.showInputError("你需要输入一些信息。"); return false
        }
        callback(inputValue);
    });
}


//ajax操作
function showAjax(msg,text,callback) {
    msg = msg || '';
    text = text || '';
    if(typeof(callback) == 'function'){
      callback = callback;
    }else{
      callback = function(isConfirm){
        swal({ title: "", text: "", timer: 0, showConfirmButton: false });
      }
    }
    swal({
        title: msg,
        text: text,
        type: "info",
        showCancelButton: true,
        closeOnConfirm: false,
        showLoaderOnConfirm: true,
    }, callback);
}


// 提交等待提示
function wait_prompt(flag = false) {
    if(flag === true){
        $('.wait_prompt').show();
    }else{
        $('.wait_prompt').hide();
    }
}
